package org.apache.ocean;

import org.apache.lucene.document.Document;

/**
 * 
 * @author jasonr
 */
public class CScoreDocument {
	public CScoreDoc scoreDoc;
	public Document document;

	public CScoreDocument() {
	}

	public CScoreDocument(CScoreDoc scoreDoc, Document document) {
		this.scoreDoc = scoreDoc;
		this.document = document;
	}

	public OceanDocument toOceanDocument(IndexSchema indexSchema) throws Exception {
		OceanDocument oceanDocument = ClusterUtil.toOceanDocument(document, indexSchema);
		oceanDocument.add(ClusterConstants.SCORE_FIELD, new CDouble(scoreDoc.score));
		return oceanDocument;
	}

	/**
	 * public OceanDocument toOceanDocument(IndexSchema indexSchema) throws
	 * Exception { List<Fieldable> list = document.getFields(); OceanDocument
	 * oceanDocument = new OceanDocument(); for (Fieldable fieldName : list) {
	 * Fieldable[] fieldables = document.getFieldables(fieldName); if (fieldables !=
	 * null) { process(fieldables, oceanDocument, indexSchema); } } return
	 * oceanDocument; }
	 * 
	 * private void process(Fieldable[] fieldables, OceanDocument oceanDocument,
	 * IndexSchema indexSchema) throws Exception { oceanDocument.add("score", new
	 * CDouble(scoreDoc.score)); for (Fieldable fieldable : fieldables) { if
	 * (fieldable.isStored()) { String fieldName = fieldable.name(); String
	 * indexedValue = fieldable.stringValue(); SchemaField schemaField =
	 * indexSchema.getField(fieldName); FieldType fieldType =
	 * schemaField.getFieldType(); if (StringUtils.isNotBlank(indexedValue)) {
	 * Object value = ClusterUtil.toObjectFromIndexed(fieldName, indexedValue,
	 * indexSchema); oceanDocument.add(fieldName, value); } } } }
	 */
}
